package com.example.administrator.yuejian2.model;

import com.example.administrator.yuejian2.RetrofitListener.RetrofitListener;
import com.example.administrator.yuejian2.bean.MyAttentionClubBean;
import com.example.administrator.yuejian2.service.MyAttentionService;
import com.example.administrator.yuejian2.service.MyService;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.administrator.yuejian2.other.Url.BASEURL;
import static com.example.administrator.yuejian2.other.Url.URL1;
import static com.example.administrator.yuejian2.other.Url.URL4;

public class MyAttentionClubModel {
    private Retrofit retrofit;
    private MyAttentionService myAttentionService;

    public MyAttentionClubModel()
    {
        retrofit=new Retrofit.Builder()
                .baseUrl(BASEURL+URL1)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        myAttentionService=retrofit.create(MyAttentionService.class);
    }
    public void getMyAttentionClub(String user_id, final RetrofitListener listener)
    {
        Call<List<MyAttentionClubBean>> call=myAttentionService.myAttentionClub(user_id);
        call.enqueue(new Callback<List<MyAttentionClubBean>>() {
            @Override
            public void onResponse(Call<List<MyAttentionClubBean>> call, Response<List<MyAttentionClubBean>> response) {
                listener.onSuccess(response.body(),1);
            }

            @Override
            public void onFailure(Call<List<MyAttentionClubBean>> call, Throwable t) {
                listener.onFail();
            }
        });
    }
}
